<?php
if ($portlet_menu_ParentPage==null) $parentId="null"; else
    $parentId=getObjByKey("portal_pages","id","portalId",$portalId,"name",$portlet_menu_ParentPage);
$rs=getPortalMenu($parentId,"ASC");

if ($portlet_menu_disablejs=="TRUE") { ?>



					<div  id="navigation" class="navigation">
						<ul id="jsmenuid_<?php echo $portletID; ?>" >
							<?php
							while ( !$rs->EOF)  {
								if (canView("portal_pages",$rs->fields["id"])) {
									$link=createNiceUrl("pageName",$rs->fields["name"]);
									if ($rs->fields["type"]=="B") $link="#";
									$selected="";
							             if ($rs->fields["name"]==getParameter("pageName") || $rs->fields["name"]==getParameter("category")) $selected="selected";
              ?>
 <a href="<?php echo $link; ?>">
 <li class="<?=$selected?>" id="menu_<?=$rs->fields["name"]?>"> 

 <span >

      <?php if ($rs->fields["logo_file"]!="") { ?>
                  <img src="<?php echo $rs->fields["logo_file"]; ?>">
                      <?php } else { ?>
      <?php echo $rs->fields["title"]; ?>
                  <?php }  ?>
</span>
										
									</li> </a>
									<?php
								}

								$rs->MoveNext();
							}
							?>
						</ul>
					</div>



<?php }else{   ?>

<script>
$(document).ready(function(){
    

    $("#jsmenuid_<?php echo $portletID; ?>").superfish({
        delay:       1000,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    }
		);


}); 
</script>

 <div  id="navigation"> 
 <ul id="jsmenuid_<?php echo $portletID; ?>" class="sf-menu sf-js-enabled sf-shadow">
 <?php
          while ( !$rs->EOF)  { 
		 if (canView("portal_pages",$rs->fields["id"])) {

             $link=createNiceUrl("pageName",$rs->fields["name"]);
             if ($rs->fields["type"]=="B") $link="#";
             $selected="";
             if ($rs->fields["name"]==getParameter("pageName") || $rs->fields["name"]==getParameter("category")) $selected="selected";
              ?>

 <li class="<?=$selected?>" id="menu_<?=$rs->fields["name"]?>"> 

 <span class="navigation">
  <a href="<?php echo $link; ?>">
      <?php if ($rs->fields["logo_file"]!="") { ?>
                  <img src="<?php echo $rs->fields["logo_file"]; ?>">
                      <?php } else { ?>
      <?php echo $rs->fields["title"]; ?>
                  <?php }  ?>
  </a></span>
 <?php

$rschild=getPortalMenu($rs->fields["id"],"ASC"); 
  $hasChilds=false;

  //echo "<script>alert('".$rschild->EOF."');</script>";
if (!$rschild->EOF){
$hasChilds=true;
?>
<ul class="child" >
<?php
}
			?>
 <?php
          while ( !$rschild->EOF)  {

        if (canView("portal_pages",$rschild->fields["id"])) {

            $pageName =$rschild->fields["name"];
            $url=createNiceUrl("pageName",$pageName);

            $system_pageName=$pageName;
            if ($rschild->fields["type"]=="L")
                //
                $url=$rschild->fields["url"];

            $pattern='<<pageName>>';
            $replacement=$pageName;
            $url=preg_replace($pattern, $replacement, $url);

//

		  ?>
  <li>

      <?php if ($rschild->fields["logo_file"]!="") { ?>
                <img src="<?php echo getFileManagerImage('image',$rschild->fields["logo_file"]) ?>"/>
                <?php }  ?>

  <a href="<?php echo $url; ?>"><?php echo $rschild->fields["title"]; ?></a> </li>
                  <?php
           }
		  $rschild->MoveNext();    
		  }
if ($hasChilds){
?>
</ul>
<?php
}	
?>
   </li>
              <?php
          }

		  $rs->MoveNext();    
		  }
?>
</ul>
 </div>


<?php }  ?>